/*
 * =============================================================================
 * Copyright© by Benjamin Sempere,
 * All rights reserved.
 * =============================================================================
 * Author  : Benjamin Sempere
 * E-mail  : benjamin@sempere.org
 * Homepage: www.sempere.org
 * =============================================================================
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package org.sempere.gwt.toolbox.core.client.common;

import java.util.Collection;

public interface Observable {

	/**
	 * Return the name of this observable
	 * 
	 * @return String
	 */
	String getObservableName();

	/**
	 * Add an observer to this observable
	 * 
	 * @param observer the observer to add
	 */
	void addObserver(Observer observer);

	/**
	 * Add several observers to this observable
	 * 
	 * @param observers the observers to add
	 */
	void addObservers(Collection<Observer> observers);

	/**
	 * Remove an observer from this observable
	 * 
	 * @param observer the observer to remove
	 */
	void removeObserver(Observer observer);

	/**
	 * Remove several observers from this observable
	 * 
	 * @param observers the observers to remove
	 */
	void removeObservers();

	/**
	 * Return the number of registered observers to this instance
	 * 
	 * @return int
	 */
	int countObservers();

	/**
	 * Notify registered observers that this instance has changed
	 */
	void notifyObservers();

	/**
	 * Notify registered observers that this instance has changed
	 * 
	 * @param context execution context (helpful for passing parameters)
	 */
	void notifyObservers(Object context);

	/**
	 * Say if this observable instance has changed
	 * 
	 * @return true if this instance has changed, false otherwise
	 */
	boolean hasChanged();

	/**
	 * Notify that this observable instance has changed
	 */
	void setChanged();

	/**
	 * Reset change state to its initial value (false)
	 */
	void clearChanged();
}